<?php
session_start();
include_once('libs/db.php');


if (isset($_GET[ 'id_elemento' ])) {
	$query = "UPDATE elementos SET update_st = 1, update_ts = NOW() WHERE id_elemento = ".$_GET[ 'id_elemento' ];
	$result = @mysql_query($query);
	if ($result) {
		header('Location:list_elementos.php');
		exit;
	}
	$str_error .=  "<br />ERROR AL ELIMINAR elemento.";
}
$query = "SELECT * ,
          CONCAT(valor, '-' , e.codigo_unidad, '-',e.codigo_b, '-',e.codigo_c, '-',e.codigo_d, '-',e.codigo_extra  ) elemento
          FROM elementos e , config_global c 
          WHERE  propiedad = 'abreviatura' and 
                 e.update_st = 0 
          ORDER BY e.update_ts desc 
          LIMIT 10;";
$result = @mysql_query($query);
?>
<html>
<head>
<script src='javascript\list_elementos.js'></script>
<LINK href="common.css" rel="stylesheet" type="text/css">
</head>

<?php include_once('htx/header.php');?>

<div align=center style='top:100px' >
<fieldset id='fieldset' >
<legend>Listado elementos</legend><br />
<table id='tbl_abm' align=center cellpadding='0' cellspacing='0'>
<tr>
	<th>Id</th>
	<th>PSN-UT</th>
	<th>Descripcion</th>
 	<th colspan=3 ></th>
</tr><?php 
$i = 1;
while ($row = @mysql_fetch_assoc($result)) {
	$bg = ($i % 2 == 0) ? "#dce9f2" : "";
	$i++;
	
	print "<tr bgcolor='{$bg}'>";
	print "<td nowrap>".$row[ 'id_elemento' ]."</td>";
	print "<td nowrap>".$row[ 'elemento' ]."</td>";
	print "<td nowrap>".$row[ 'descripcion' ]."</td>";
	print "<td><a href='javascript:del_elemento({$row[ 'id_elemento' ]},\"{$row[ 'nombre' ]}\")' title='Click para eliminar la unidad de medida'>";
	print "<img src='images/cancel.png' border=0 align=center /></a></td>";
	
	print "</tr>";
}?>
</table>
<table align=center >
<tr>
	<td><button name='btn_salir' class='button' onclick='javascript:volver()' ><img src='images/cancel.png' align=center /> Volver</button></td>
	<td><button name='btn_new' class='button' onclick='javascript:new_elemento()' ><img src='images/spanner_16.png' align=center /> Agregar elemento </button></td>
</tr>
</table></fieldset>
</div>

</body>
</html>
